import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;

public class WindowListenerTest extends JFrame implements WindowListener {

	public WindowListenerTest() {
		setTitle("WindowListener");
		setSize(300, 300);
		Container c = getContentPane();
		c.setLayout(new FlowLayout());
		addWindowListener(this);
	}
	@Override
	public void windowActivated(WindowEvent arg0) {
		System.out.println("Window Activated");
	}
	@Override
	public void windowClosed(WindowEvent arg0) {
		System.out.println("Window Closed");
		dispose();
		System.exit(0);
	}
	@Override
	public void windowClosing(WindowEvent arg0) {
		System.out.println("Window Closing");
	}
	@Override
	public void windowDeactivated(WindowEvent arg0) {
		System.out.println("Window Deactivated");
	}
	@Override
	public void windowDeiconified(WindowEvent arg0) {
		System.out.println("Window Deiconified");
	}
	@Override
	public void windowIconified(WindowEvent arg0) {
		System.out.println("Window Iconified");
	}
	@Override
	public void windowOpened(WindowEvent arg0) {
		System.out.println("Window Opened");	
	}
	public static void main(String[] args) {
		WindowListenerTest wl = new WindowListenerTest();
		wl.setVisible(true);
	}


}
